home *** CD-ROM | disk | FTP | other *** search
- Path: news.wlv.ac.uk!usenet
- From: Mirad Maglic <c9583772@wlv.ac.uk>
- Newsgroups: comp.lang.c
- Subject: Re: How do you reset the computer using C on a PC ?
- Date: 20 Mar 1996 16:03:30 GMT
- Organization: University of Wolverhampton, U.K.
- Message-ID: <4ipa8i$2bb@ccuh.wlv.ac.uk>
- References: <31473FD4.48AA@ccis.com> <Pine.A32.3.91.960313183048.180818A-100000@red.weeg.uiowa.edu> <4ibj64$u2@hermes.is.co.za>
- NNTP-Posting-Host: ma154-bj.wlv.ac.uk
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
-
- jfk@teamserve.paradigm.co.za (Jan Kaluza) wrote:
- >The Amorphous Mass (robinson@blue.weeg.uiowa.edu) wrote:
- >: On Wed, 13 Mar 1996, Derek Lund wrote:
- >:
- >: > Help?
- >:
- >: int main(void)
- >: {
- >: printf("press ctrl-alt-del.");
- >: return 0;
- >: }
- >:
- >: For a more useful answer, try comp.os.msdos.programmer.help (or
- >: comp.os.ms-windows.programmer, etc).
- >:
- >: /**James Robinson***********************
- >: "If a fatal error occurs, the program should not be allowed to continue."
- >: -- Oracle Pro*C User's Guide *************james-robinson@uiowa.edu**/
- >
- >More seriously: when you want to reset the PC, call this function:
- >
- >void resetPC(void) {
- > struct REGPACK rr;
- > intr(25,&rr);
- >}
- >
- >This works for Turbo C/Borland C. For other compilers there must be an
- >equivalent. Interrupt 25 resets the PC in DOS. I found it hangs up a
- >DOS session in Windows rather nastily.
- >--
- >Jan KALUZA: jfk@paradigm.co.za [Box 4687, The Reeds, 0158, RSA] |Psalm
- >Genghis Janus (Std Disclaimer: My views are mine, mine and mine again!) |97:11
- >Light is sown as seed for the righteous and gladness for the upright in heart.
-
-
- Yeah, but you have to include dos.h. If you don't want to try this:
-
-
- /*
- Reboot from C
-
- The program below works in TurboC (or MS C). In some compilers, you
- have to fold the address to 20 bits, but here the segment and offset
- are separate.
- */
-
- #define MAGIC 0 /* for cold restart */
- /* #define MAGIC 0x1234 /* for warm restart */
-
- #define BOOT_SEG 0xffffL
- #define BOOT_OFF 0x0000L
- #define BOOT_ADR ((BOOT_SEG << 16) | BOOT_OFF)
-
- #define DOS_SEG 0x0040L
- #define RESET_FLAG 0x0072L
- #define RESET_ADR ((DOS_SEG << 16) | RESET_FLAG)
-
- void main()
- {
- void ((far *fp)()) = (void (far *)()) BOOT_ADR;
-
- *(int far *)RESET_ADR = MAGIC;
- (*fp)();
- }
-
-
- It works fine from DOS but Windows gives message that application has
- *violated system integrity* whatever that means.
-
-
- Mirad Maglic (c9583772@wlv.ac.uk
-
-